package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.YmtActivityStock;

public class YmtActivityStockWapper {
	SqlManager manage;

	public YmtActivityStockWapper() {
		manage = new SqlManager("intpro");
	}
	
	public List<YmtActivityStock> selectByProductId(String productId)throws InterruptedException{
		  @SuppressWarnings("unchecked")
		List<YmtActivityStock>  ymtActivityStock = manage.getSelectResults(
		            "com.ymttest.database.mapping.YmtActivityStockMapper.selectByProductId", productId);
		    manage.commit();
		    return ymtActivityStock;
	}

	public void updateActivityStockByCatalogs(String catalogId,int num){
			Map m = new HashMap();
			m.put("catalogId",catalogId);
			m.put("number",num);
			manage.update("com.ymttest.database.mapping.YmtActivityStockMapper.updateActivityStockByCatalogs", m);
			manage.commit();
	}
	
	public YmtActivityStock selectByCatalogIdAndActivityId(String catalogId,int activityId)throws InterruptedException{
		  @SuppressWarnings("unchecked")
		  
		  Map m = new HashMap();
			m.put("sCatalogId", catalogId);
			m.put("iActivityID", activityId);
			
		List<YmtActivityStock>  ymtActivityStock = manage.getSelectResults(
		            "com.ymttest.database.mapping.YmtActivityStockMapper.selectByCatalogIdAndActivityId", m);
		    manage.commit();
		    return ymtActivityStock.get(0);
	}
	
	
	public static void main(String[] args) throws InterruptedException {
		new YmtActivityStockWapper().updateActivityStockByCatalogs("c1430247",200);
	}
}
